<html>
	<head>
		<title>Test</title>
		<script src="jsunit/app/jsUnitCore.js"></script>
		<script language="JavaScript" type="text/javascript"></script>
		<script src='MockFun.js'></script>
		<script>

		/*
		 * Function to be mocked.
		 */
    function showValidateResult(isCorrort, errorHolder, errorMsg) {}

		function showComponent(componentId) {}
		
		function hideComponent(componentId) {}
		
    /*
     * Function to test.
     */ 
    function enableComponent(componentId, isEnable, other1, other2) {
      if (isEnable) {
        showComponent(componentId);
        return getComponentCoordinate(); // defined @ other file
      }	else {
        hideComponent(componentId);
        showValidateResult(true, other1, other2);	
      }
    }

    /*
     * Unit test with MockFun
     */
   	function testEnableComponent() { 
   		var m1 = mock('showComponent').expect(1);
   		var m2 = mock('getComponentCoordinate').thenReturn([100, 200]);
   		
   		var coordinate = enableComponent('id', true, null, null);
   		assertArrayEquals([100, 200], coordinate);
   		
   		m1.verify().renew();
   		m2.verify().renew();
   	}
   	
   	function testEnableComponent2() {
   		var m1 = mock('hideComponent').expect(1);
   		var m2 = mock('showValidateResult').expect(1);
   		enableComponent('id', false, null, null);
   		
   		m1.verify().renew();
   		m2.verify().renew();  			
   	}
   	
   	function testInvokedMultiTimes() {
   			var m = mock('getRandomName').thenReturnThem('Si', 'Han', 'Tom');
   			assertEquals('Si', getRandomName());
   			assertEquals('Han', getRandomName());
   			assertEquals('Tom', getRandomName());
   			m.verify().renew();
   	}
   	
   </script>
  </head>
 	<body>
	</body>
</html>